#ifndef YCCORERECORDMODEL_H
#define YCCORERECORDMODEL_H

#include "recordinfo.h"
#include <QHash>
#include <QList>
#include <QObject>

namespace yc {

class RecordModel : public QObject
{
    Q_OBJECT
public:
    explicit RecordModel(QObject* parent = nullptr);
    ~RecordModel();

    const QList<RecordInfo*>& records() const { return records_; }
    RecordInfo* record(int id) const;
    void add(const RecordInfo& ri);
    void remove(int id);
    void clear();

    int presenterCurrentCount(int presenter) const;
    int presenterTotalCount(int presenter) const { return presenter_counts_.value(presenter); }
    void setPresenterTotalCount(int presenter, int count)
    {
        presenter_counts_.insert(presenter, count);
    }
    bool hasPresenterTotalCount(int presenter) const
    {
        return presenter_counts_.contains(presenter);
    }

Q_SIGNALS:
    void added(yc::RecordInfo* record, QPrivateSignal);
    void removed(yc::RecordInfo* record, QPrivateSignal);
    void modelAboutToBeReset(QPrivateSignal);
    void modelReset(QPrivateSignal);

private:
    QList<RecordInfo*> records_;
    QHash<int, int> presenter_counts_;
};

} // namespace yc

#endif // YCCORERECORDMODEL_H
